<%include ../common/include_header1.html%>

            <div class="cont">
            	<%include menu.html%>
            <div class="right">
              <div class="huisheng-success-wrap clearfix">
                <div class="huisheng-success" style="background: url(/web/images/success.jpg) no-repeat;"></div>
              </div>
                 <div class="lj">
                    <a href="/index.html"><img src="/web/images/tb6.png"></a> |
                    <a href="#"></a><a href="/index.html">首页</a>&gt; <a href="/company_dynamic/dynamic">业界荣誉</a> &gt; <a href="javascript:void(0)" id="mtitle"></a>
                    <!-- <a href="#">企业简介</a> -->
                </div>
                <div class="right_nr">
                   <div class="tp-ls clearfix">
                        <ul id="mr_fu">
                                                    
                          
                        </ul>
                    </div>
                    <div class="admin-table-page">
                            <div id="page" class="page">
                            </div>
                        </div>
                </div>
            </div>
            <div class="clear"></div>
            <style type="text/css">
            	.page{    text-align: center;
    font-size: 14px;
    margin: 40px 30px;}
            	.page a{    color: #000;
    border: 1px solid #ededed;
    background: #fbfcfb;
    padding: 5px 10px;margin-left: 4px;}
    .page a:hover {
    color: #f00000;
}
.layui-laypage-curr{  color: #000;
    border: 1px solid #ededed;
    background: #fbfcfb;
    padding: 5px 10px;}
    .layui-laypage-curr em{font-style: normal;}
    .layui-laypage-curr em:hover{color: #f00000;}
            </style>
        </div>
<script type="text/javascript" src="/web/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.use(['layer', 'laypage','form'], function(){
        var layer = layui.layer
                ,laypage = layui.laypage
                , $ = layui.jquery;
 		 var value="<%=value%>";
        //页面初始化的时候执行
        $(function (){
            $("#news").addClass("active");
           //第一个参数：多少页，第二个参数，新闻类型，0企业动态，1媒体报道，2活动报道
          
           switch(value){
           	case 'luban_award':getData(1,0);
           		$("#mtitle").text("鲁班奖工程")
           	break;
           	case 'national_quality':getData(1,1);
           		$("#mtitle").text("国家优质工程")
           	break;
           	case 'safe_civilization':getData(1,2);
           		$("#mtitle").text("AAA级安全文明工地")
           	break;
           	case 'district_quality':getData(1,3);
           		$("#mtitle").text("区优质工程")
           	break;
           	case 'other_awards':getData(1,4);
           		$("#mtitle").text("其他获奖工程")
           	break;
           	
           }
          
            
        });

        //从后台获取数据函数，获取页数curr的数据
        function getData(curr,category){
            $.post("/web/get_honor_by_Category1",{curr:curr,category:category},function(result){
                //拼接html内容
                var tabContent="";
                //获取后台json数据
                var mydata=result.data;
                console.log(result)
                for(var i=0;i<mydata.length;i++){
                	var content=mydata[i].content
                	var title=mydata[i].title;
                	title=title.slice(0,50);
						var imgReg = /<img.*?(?:>|\/>)/gi;
						//匹配src属性 
						var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
						var arr = content.match(imgReg);
						
						if(arr){
						var src = arr[0].match(srcReg);
							mydata[i].img=src[1].toString();
						}else{
							mydata[i].img='/web/images/noimg.jpg';
						}
						var content=mydata[i].content;
//			        	content=content.match(/<p>(.+)<\/p>/)[1];
			        	content=content.replace(/<[^>]+>/g,"");//去掉所有的html标记
			        	if(content.length>150){
		            		content=content.slice(0,150)+'...'
		            	}
                	var tempStr='<li><a href="/honor_detail1/'+mydata[i]._id+'" title="'+title+'">'+
                                '<div class="b_img"><div class="jqthumb" style="width: 300px; height: 180px;"><div style="width: 100%; height: 100%;'+
                                ' background-image: url(&quot;/'+mydata[i].img+'&quot;); background-repeat: no-repeat; background-position: 50% 50%; background-size: cover;"></div></div><img src="/'+mydata[i].img+'" style="display: none;"></div>'+
                                '<span>'+title+'</span>'+
                                '<p>'+content+'</p></a></li>'
                	tabContent+=tempStr;
//                  var tempStr='<tr id='+mydata[i]._id+'>'+
//                              /*序号分页后也必须得变动,每页十条数据*/
//                          '<td>'+(i+(curr-1)*10+1)+'、 <a href="/news_detail/'+mydata[i]._id+'" class="a_color">'+mydata[i].title+'</a><span class="pull-right">'+mydata[i].time+'</span></td>'+
//                          '</tr>'
                    
                }
                //将拼接好的数据填入#tabContent中
                
                $(".tp-ls ul").eq(0).html(tabContent);
                //显示分页
                laypage({
                    cont: 'page', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
                    pages: result.pages, //通过后台拿到的总页数
                    curr: curr || 1, //当前页
                    skin: '#c52d2f',
                    layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'],
                    jump: function(obj, first){ //触发分页后的回调
                        if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                        	switch(value){
					           	
					           	case 'luban_award':	getData(obj.curr,0);break;
					           	case 'national_quality ':	getData(obj.curr,1);break;
					           	case 'safe_civilization':	getData(obj.curr,2);break;
					           	case 'district_quality':	getData(obj.curr,3);break;
					           	case 'other_awards':	getData(obj.curr,4);break;
					           }
                        }
                    }
                });
                
            });
        };
    });
</script>
<%include ../common/include_footer1.html%>
    

  